package com.chenyun.rpc.dubbo.config;

import com.chenyun.common.factory.YAMLPropertySourceFactory;
import com.chenyun.rpc.dubbo.satoken.SaTokenSecondContextCreatorForDubbo3;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.Serializable;

/**
 * dubbo 3配置文件
 *
 * @author: Lonni
 * @date: 2024/1/22 0022 16:29
 */
@Configuration
@ConditionalOnProperty(value = "chenyun.rpc.type", havingValue = "dubbo", matchIfMissing = false)
@Slf4j
@EnableDubbo(scanBasePackages = {"com.chneyun", "com.lonni"})
@PropertySource(value = "classpath:config/application-dubbo.yml", factory = YAMLPropertySourceFactory.class)
public class Dubbo3Config implements Serializable {
    public Dubbo3Config() {
        log.info("加载dubbo配置");
    }

    @Bean
    public SaTokenSecondContextCreatorForDubbo3 saTokenSecondContextCreatorForDubbo3() {
        return new SaTokenSecondContextCreatorForDubbo3();
    }


}



